package com.mapper;
import com.pojo.Course;
import com.pojo.User;
import org.apache.ibatis.annotations.*;
import org.apache.ibatis.mapping.FetchType;
import java.util.List;

@Mapper
public interface CourseMapper {
    @Select("SELECT ke.*,uk.k_id,uk.u_id FROM kecheng_chen ke JOIN user_ke uk on ke.id=uk.k_id join user_chen u on u.id=uk.u_id where u.id=#{id}")
    @Results({
            @Result(property = "id", column="id",id = true),
            @Result(property = "title",column = "title"),
            @Result(property = "image",column = "tupian"),
            @Result(property = "userList",column = "ke.id",many = @Many(select = "com.mapper.CourseMapper.selectUser",fetchType = FetchType.LAZY))
    })
    List<Course> selectAll(Course course);
    @Select("select u.id from user_chen u join user_ke uk on uk.u_id=u.id where uk.u_id=#{id};")
    List<User> selectUser(Integer id);
}
